Custom Resource (k8s)
#wip
https://kubernetes.io/ja/docs/concepts/extend-kubernetes/api-extension/custom-resources/
Kubernetes Resourceを拡張したもの
/mrsekut-book-4295012750/026
GPT-4.icon
Custom Resourceとは、Kubernetes標準には存在しないリソースをユーザーが独自に定義して利用できる仕組みのことです。
例えば、DeploymentやServiceのような標準リソース以外に、自社サービス特有の概念を表現したリソースをKubernetesに追加できます。
利用シーン例
「Database」というCustom Resourceを定義し、YAMLでデータベース構成を記述できるようにする。
「Application」や「CronJobSet」など、自社の特有の業務要件を抽象化して管理できるようにする。
作成方法
Custom Resourceは「Custom Resource Definition (CRD)」というKubernetesリソースを使って定義します。
code:yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: databases.example.com
spec:
group: example.com
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
size:
type: integer
scope: Namespaced
names:
plural: databases
singular: database
kind: Database